package designPattern.observer;

import java.util.Vector;

public abstract class AbstractSubject implements Subject {

    private Vector<Observer> observerList;

    AbstractSubject() {
        observerList = new Vector<>();
    }

    @Override
    public void registerObserver(Observer observer) {
        observerList.add(observer);
    }

    @Override
    public void removerObserver(Observer observer) {
        boolean remove = observerList.remove(observer);
    }

    @Override
    public void notifyObserver() {
        observerList.stream().forEach(o -> o.update(this));
    }

    @Override
    public void operation() {
        notifyObserver();
    }
}
